﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Com.Web.coffinegurunaru.AppLogic.Page;
using Com.Framework;
using Com.Framework.Data;
using Com.Library.DB.User;
using Com.Library.DB.UserCard;
using Com.Library.Page;

namespace Com.Web.coffinegurunaru.manager.usercard
{
	public partial class usercardmethod : ManagerAjaxPage
	{
		public string[] GetList(byte CodeStatus, string CardNo, string UserID, int PageNo, byte PageSize)
		{
			int? UserNo = null;
			string[] retValue = new string[3];

			if (UserID != string.Empty)
			{
				UserEntity info = UserModel.UserInfo(UserID);
				if (info.UserNo == 0)
				{
					retValue[0] = string.Empty;
					retValue[1] = "0";
					retValue[2] = "존재하지 않는 아이디입니다.";
					return retValue;
				}
				UserNo = info.UserNo;


			}
			ListData<UserCardManagerEntity, OutputEntity> result = UserCardModel.GetListManager((CodeCardStatus)CodeStatus, UserNo, CardNo, PageNo, PageSize);

			Dictionary<string, object> properties = new Dictionary<string, object>();
			properties.Add("CardList", result.Record);
			properties.Add("CodeStatus", CodeStatus);
			retValue[0] = ViewManager<ManagerPage>.Render("/manager/usercard/cardlist.ascx", properties);
			retValue[1] = result.Output.CntTotal.ToString();
			retValue[2] = string.Empty;

			return retValue;
		}

		public void Remove(int UserCardNo, string Desc)
		{
			UserCardModel.Remove(UserCardNo, this.WebCookies.ManagerName, Desc);
		}

		public void Restore(int UserCardNo)
		{
			UserCardModel.Restore(UserCardNo, this.WebCookies.ManagerName, string.Empty);
		}
	}
}
